import Vue from 'vue'
import VueResource from 'vue-resource'
import VueRouter from 'vue-router'
import VueQuillEditor from 'vue-quill-editor'
import ElementUI from 'element-ui'
import 'normalize.css/normalize.css'
import 'element-ui/lib/theme-default/index.css'
import App from './App'
import CatworkLogin from './components/Catwork/Login.vue'
import ChangePassword from './components/Catwork/ChangePassword.vue'
import CatworkLayout from './components/Catwork/Layout.vue'
import Welcome from './components/Catwork/Welcome.vue'
import LStorage from './store/LStorage'

// business
import AlbumList from './components/Catwork/PhotoAlbum/AlbumList.vue'
import PhotoList from './components/Catwork/PhotoAlbum/PhotoList.vue'
import UserList from './components/Catwork/User/UserList.vue'
import User from './components/Catwork/User/User.vue'
import FeedbackList from './components/Catwork/Feedback/FeedbackList.vue'

// vip
import Service from './components/Catwork/Vip/Service.vue'

// 拼团管理
import SettingList from './components/Catwork/Group/SettingList.vue'
import Setting from './components/Catwork/Group/Setting.vue'
import GroupList from './components/Catwork/Group/GroupList.vue'
import Statistics from './components/Catwork/Group/Statistics.vue'

// 优惠券
import CouponList from './components/Catwork/Coupon/CouponList.vue'

// 社交模块
import PersonList from './components/Catwork/Social/PersonList.vue'
import Person from './components/Catwork/Social/Requirement.vue'

import ContractList from './components/Catwork/Vip/ContractList.vue'
import MessageList from './components/Catwork/Message/MessageList.vue'
import Message from './components/Catwork/Message/Message.vue'

// 广告模块
import PositionList from './components/Catwork/Ad/PositionList.vue'
import BannerList from './components/Catwork/Ad/BannerList.vue'
import Banner from './components/Catwork/Ad/Banner.vue'

import ProtocolList from './components/Catwork/AppInfo/ProtocolList.vue'
import AboutList from './components/Catwork/AppInfo/AboutList.vue'

import store from './store'

Vue.use(VueResource)
Vue.use(VueRouter)
Vue.use(VueQuillEditor)
Vue.use(ElementUI)
Vue.use(LStorage)

Vue.http.options.root = store.state.config.ApiHostUrl
Vue.http.headers.common['Authorization'] = store.state.login.authorization

const routes = [
  {
    path: '/',
    component: App,
    children: [
      {
        path: '', redirect: '/login'
      },
      {
        path: 'login',
        component: CatworkLogin
      },
      {
        path: 'changePassword',
        component: ChangePassword
      },
      {
        path: 'workbench',
        component: CatworkLayout,
        children: [
          {
            path: 'dashboard',
            component: Welcome
          },
          {
            path: 'group/setting-list',
            name: 'group_setting.list',
            component: SettingList
          },
          {
            path: 'group/setting',
            name: 'group_setting.add',
            component: Setting
          },
          {
            path: 'group/setting/:setting_id',
            name: 'group_setting.edit',
            component: Setting
          },
          {
            path: 'group/group-list',
            name: 'group_group.list',
            component: GroupList
          },
          {
            path: 'group/statistics',
            name: 'group_statistics',
            component: Statistics
          },
          {
            path: 'coupon/coupon-list',
            component: CouponList
          },
          {
            path: 'vip/service/:service_id',
            name: 'vip_service.edit',
            component: Service
          },
          {
            path: 'social/person-list',
            component: PersonList
          },
          {
            path: 'social/person',
            component: Person
          },
          {
            path: 'photo-album/album-list/:user_id',
            component: AlbumList
          },
          {
            path: 'photo-album/photo-list/:album_id',
            component: PhotoList
          },
          {
            path: 'user/user-list',
            component: UserList
          },
          {
            path: 'user/user/:user_id',
            component: User
          },
          {
            path: 'feedback/feedback-list',
            component: FeedbackList
          },
          {
            path: 'feedback/feedback/:feedback_id',
            component: FeedbackList
          },
          {
            path: 'vip/contract-list',
            component: ContractList
          },
          {
            path: 'message/message-list',
            component: MessageList
          },
          {
            path: 'message/message',
            component: Message
          },
          {
            path: 'ad/banner-list',
            component: BannerList
          },
          {
            path: 'ad/banner',
            component: Banner
          },
          {
            path: 'ad/position-list',
            component: PositionList
          },
          {
            path: 'app-info/about-list',
            component: AboutList
          },
          {
            path: 'app-info/protocol-list',
            component: ProtocolList
          }
        ]
      }
    ]
  }
]

const router = new VueRouter({
  routes // （缩写）相当于 routes: routes
})

new Vue({
  router,
  store
}).$mount('#root')

/* eslint-disable no-new */
/* new Vue({
  el: '#app',
  template: '<App/>',
  components: { App }
}) */
